<template>
    <el-container>
        <el-main>
            <el-table :data="tableData">

                <el-table-column
                        prop="processDefinitionName"
                        label="流程名称"
                >
                </el-table-column>

                <el-table-column
                        prop="name"
                        label="任务节点"
                >
                </el-table-column>

                <el-table-column
                        prop="created"
                        label="创建时间"
                >
                    <template slot-scope="scope">
                        {{formatDate(scope.row.created)}}
                    </template>
                </el-table-column>

                <el-table-column
                        prop="name"
                        label="操作"
                        width="300"
                >
                    <template slot-scope="scope">
                        <el-button @click="claimTask(scope.row)" size="mini">领取任务</el-button>
                        <el-button @click="approve(scope.row)" size="mini">审批</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
    </el-container>
</template>

<script>
    import {getTaskList} from '../../api/task.api'

    export default {
        name: "TaskManager",
        data() {
            return {
                tableData: []
            }
        },
        methods: {
            loadTask() {
                getTaskList({
                    assignee: "ddshuai",
                    assignment: "involved",
                    page: 0,
                    sort: "created-desc",
                    state: "open"
                }).then((res) => {
                    this.tableData = res.data
                })
            },
            claimTask() {

            },
            approve(row) {
                this.$store.commit('setApproveTaskId', row.id)
                this.$router.push('task-approve');
            }
        },
        created() {
            this.loadTask();
        }
    }
</script>

<style scoped>

</style>
